package com.genesis.yunnanji.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.genesis.yunnanji.R;
import com.genesis.yunnanji.activity.CultureHouse;
import com.genesis.yunnanji.activity.Specialty;
import com.genesis.yunnanji.activity.Sup;
import com.genesis.yunnanji.utils.GenesisUtils;

/**
 * Created by Administrator on 2017/11/7.
 */

public class HomeCate1 extends Fragment implements View.OnClickListener {
    private LinearLayout sup;
    private LinearLayout house;
    private LinearLayout specialty;
    private LinearLayout rushroom;
    private LinearLayout culture;
    private View view;
    private Intent intent;
    private GenesisUtils genesisUtils;


    public static HomeCate1 newInstance(String param) {
        HomeCate1 obj = new HomeCate1();
        Bundle bundle = new Bundle();
        bundle.putString("args1", param);
        obj.setArguments(bundle);
        return obj;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (view == null) {
            view = this.getActivity().getLayoutInflater().inflate(R.layout.fragment_homepage_cate, null);
            sup = (LinearLayout) view.findViewById(R.id.homepage_cate_feel);
            house = (LinearLayout) view.findViewById(R.id.homepage_cate_house);
            specialty = (LinearLayout) view.findViewById(R.id.homepage_cate_special);
            rushroom = (LinearLayout) view.findViewById(R.id.homepage_cate_rushroom);
            culture = (LinearLayout) view.findViewById(R.id.homepage_cate_culture);
            genesisUtils = GenesisUtils.getIntance();

            initView();
        } else {
            ViewGroup parent = (ViewGroup) view.getParent();
            if (parent != null) {
                parent.removeView(view);
            }
        }
        return view;
    }

    protected void initView() {
        sup.setOnClickListener(this);
        house.setOnClickListener(this);
        specialty.setOnClickListener(this);
        rushroom.setOnClickListener(this);
        culture.setOnClickListener(this);
    }


    protected void setUpView() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.homepage_cate_feel:
                intent = new Intent(this.getContext(), Sup.class);
                startActivity(intent);
                break;
            case R.id.homepage_cate_house:
                intent = new Intent(this.getContext(), CultureHouse.class);
                intent.putExtra("url", "http://m.jinzhanji.com/Wenlv/index.html" + "?__apptoken__=" + genesisUtils.getAppToken() + "&from=app");
                startActivity(intent);
                break;
            case R.id.homepage_cate_special:
                intent = new Intent(this.getContext(), Specialty.class);
                intent.putExtra("title", "云南特产");
                intent.putExtra("id", "1");
                startActivity(intent);
                break;
            case R.id.homepage_cate_rushroom:
                intent = new Intent(this.getContext(), Specialty.class);
                intent.putExtra("title", "云南菌库");
                intent.putExtra("id", "2");
                startActivity(intent);
                break;
            case R.id.homepage_cate_culture:
                intent = new Intent(this.getContext(), Specialty.class);
                intent.putExtra("title", "云南非遗");
                intent.putExtra("id", "15");
                startActivity(intent);
                break;

        }

    }
}
